import { Injectable } from '@angular/core';

@Injectable({
  providedIn: 'root'
})
//提供一个可以注册的服务
export class StorageService {
  count:number=1;
  
  constructor() { } 

  //将数据写入localStorage
  set(key:any,value:any){
    localStorage.setItem(key,JSON.stringify(value))
  }
  //localStorage读取数据，转化为json对象
  get(key:any){
    return JSON.parse(localStorage.getItem(key));
  }
  // localStorage中删除key的值
  remove(key:any){
    localStorage.removeItem(key);
  }


}
